import Card from "antd/es/card/Card";
import { Button, Checkbox, Form, Input, Select, Space, Spin, InputNumber, Table, DatePicker } from 'antd';
import React, { useEffect, useRef, useState } from 'react';
import _ from 'lodash';
import { useParams } from 'react-router-dom'
import JcdHandle from "../../../../../../utils/apis/JcdHandle";
import { useHistory } from "react-router-dom/cjs/react-router-dom.min";
import JcyjApi from "../../../../../../utils/apis/JcyjApi";

export default function JcdLook(props) {
    const dynamicForms = [
        // {
        //     "alias": "创建人",
        //     "name": "createBy",
        //     "type": "input"
        // }, {
        //     "alias": "创建时间",
        //     "name": "createTme",
        //     "type": "input"
        // },
        // {
        //     "alias": "最后更新人",
        //     "name": "updateBy",
        //     "type": "input"
        // },
        // {
        //     "alias": "最后更新时间",
        //     "name": "updateTime",
        //     "type": "input"
        // },
        {
            "alias": "站点名称",
            "name": "zdmc",
            "type": "input"
        },
        {
            "alias": "行政区划名称",
            "name": "xzqhmc",
            "type": "input"
        },
        {
            "alias": "行政区划编码",
            "name": "xzqhbm",
            "type": "input"
        },
        {
            "alias": "预警类别",
            "name": "yhlb",
            "type": "input"
        },

        {
            "alias": "级别颜色",
            "name": "jbys",
            "type": "input"
        },
        {
            "alias": "经度",
            "name": "jd",
            "type": "input"
        },
        {
            "alias": "纬度",
            "name": "wd",
            "type": "input"
        },
        {
            "alias": "时间",
            "name": "sj",
            "type": "input"
        },
        {
            "alias": "预警标题",
            "name": "yjbt",
            "type": "input"
        },
        {
            "alias": "是否发布",
            "name": "isfb",
            "type": "input"
        },
        {
            "alias": "预警详细内容",
            "name": "yjxxnr",
            "type": "input"
        },
        {
            "alias": "地理信息",
            "name": "geom",
            "type": "input"
        }
    ]
    const [idDatas, setIdDatas] = useState();
    const [componentDisabled, setComponentDisabled] = useState(true);
    const [jcdXqLookData, setJcdXqLookData] = useState();
    const [form] = Form.useForm();
    const [params, setParams] = useState({
        pageSize: 10,
        pageNum: 1,

    })
    const id = useParams()?.id;

    useEffect(() => {

        JcyjApi.yjList({ id: id }).then(resp => {

            setIdDatas(resp.rows)

            let a = JSON.parse(JSON.stringify(resp.rows));
            // if (a[0].xzqhbm === "511503") {
            //     a[0].xzqhbm = '翠屏区'
            // } else if (a[0].xzqhbm === "511504") {
            //     a[0].xzqhbm = '南溪区'
            // } else if (a[0].xzqhbm === "511505") {
            //     a[0].xzqhbm = '叙州区'
            // } else if (a[0].xzqhbm === "511523") {
            //     a[0].xzqhbm = '江安县'
            // } else if (a[0].xzqhbm === "511524") {
            //     a[0].xzqhbm = '长宁县'
            // } else if (a[0].xzqhbm === "511525") {
            //     a[0].xzqhbm = '高县'
            // } else if (a[0].xzqhbm === "511526") {
            //     a[0].xzqhbm = '珙县'
            // } else if (a[0].xzqhbm === "511527") {
            //     a[0].xzqhbm = '筠连县'
            // } else if (a[0].xzqhbm === "511528") {
            //     a[0].xzqhbm = '兴文县'
            // }
            console.log('22',a)
            //let xqLookData=JSON.parse(resp.rows.xq)
            form.setFieldsValue(//
                ...a,
            )
        })
    }, [id, form])
    //   useEffect(()=>{
    //     JcdHandle.jcdXqDynamicApi().then(datas=>{
    //       setJcdXqLookData(datas)
    //     })
    //   },[])
    const history = useHistory();
    const quxiaoHandle = () => {
       history.push(`/manager/Yjxxgl`)
        
    }

    return <div className='layout-h h100' style={{
        overflow: "scroll"
    }}>
        <Card className='h100 fill' style={{
            height: "1500px"
        }}>
            <Form method="post"

                form={form}>
                <header style={{
                    fontSize: 20,
                    fontWeight: "bold"
                }}>预警数据信息</header>
                <hr />

                <div className="InputForm" style={{
                    display: "flex",
                    flexWrap: "wrap"
                }}>
                    {idDatas !== undefined && dynamicForms !== undefined && dynamicForms.map((formItem) => {
                        let node;
                        switch (formItem.type) {
                            case 'select':
                                node = <Select></Select>;
                                break;
                            case 'input':

                                node = <Input

                                    //disabled={componentDisabled}
                                    style={{
                                        width: '90%',
                                        fontSize: '15px',
                                        color: '#ffffff',
                                        fontWeight: 'bold',
                                        // backgroundColor:'transparent',
                                        // opacity:'0.5'

                                    }}
                                    onChange={(e) => {

                                    }}

                                />
                                break;
                            default: break;
                        }

                        return <div style={{
                            flexBasis: "33%",
                            marginBottom: "10px"
                        }}><Form.Item
                            label={formItem.alias}
                            name={formItem.name}


                            rules={[
                                {
                                    //   required: true,
                                    disable: true

                                }
                            ]}

                        >
                                {node}
                            </Form.Item>
                        </div>
                    })}

                </div>

                {/* <div>
                    <header style={{
                        fontSize: "20px",
                        fontWeight: "bold"
                    }}>详情:</header><hr />
                </div>
                <div className="InputForm" style={{
                    display: "flex",
                    flexWrap: "wrap"
                }}>
                    {idDatas !== undefined && jcdXqLookData !== undefined && jcdXqLookData.map((formItem) => {
                        let node;
                        switch (formItem.type) {
                            case 'select':
                                node = <Select></Select>;
                                break;
                            case 'text':
                            default:
                                node = <Input

                                    disabled={componentDisabled}
                                    style={{
                                        width: '90%',
                                        fontSize: '15px',
                                        color: 'black',
                                        fontWeight: 'bold',
                                        backgroundColor: 'transparent',
                                        opacity: '0.5'

                                    }}
                                    onChange={(e) => {

                                    }}

                                />
                        }

                        return <div style={{
                            flexBasis: "33%",
                            marginBottom: "10px"
                        }}><Form.Item
                            label={formItem.alias}
                            name={formItem.name}
                            rules={[
                                {
                                    disable: true

                                }
                            ]}

                        >
                                {node}
                            </Form.Item></div>
                    })}

                </div> */}
                <div className="btn-bottom">

                    <Button onClick={quxiaoHandle} type="primary">返回</Button>
                </div>
            </Form>
        </Card>
    </div>

}